import{$ as e,D as t,Ft as n,Ht as r,Yt as i,Zn as a,_ as o,b as s,et as c,k as l,mt as u,qt as d,v as f,vn as p,w as m,xt as h,y as g}from"./CIxmKYxc4tZcJF.js";import{v as _,w as v}from"./DWlEJV-j33On0I.js";import{t as y}from"./DLyrbAGL2K8q4B.js";import{t as b}from"./DJeJfhW-4iv1Az.js";import{t as x}from"./Br8DQTtj1W9Iu5.js";var S=[`disabled`],C=[`id`,`type`,`disabled`,`aria-invalid`],w=l({inheritAttrs:!1,__name:`oui-input`,props:e({title:{},description:{},required:{type:Boolean},id:{},type:{default:`text`},lazy:{type:Boolean,default:!1},lazyDelay:{default:5e3},lazyMaxDelay:{default:6e4},disabled:{type:Boolean},clearable:{type:Boolean,default:!1},plain:{type:Boolean,default:!1},formatter:{},validator:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:e([`update`],[`update:modelValue`]),setup(e,{emit:l}){let w=e,T=l,E=n(e,`modelValue`),D=p(``),O=p(!0),k=p(null);function A(e){return w.formatter?w.formatter(e):e}function j(e){return!w.validator||w.validator(e)}let M=x({lazy:()=>w.lazy,lazyDelay:()=>w.lazyDelay,lazyMaxDelay:()=>w.lazyMaxDelay,commit:()=>{j(D.value)&&(E.value=D.value)}});r(D,e=>{let t=A(e);if(t!==e){D.value=t;return}O.value=j(t),O.value&&t!==(E.value??``)&&M.schedule()}),r(()=>E.value,e=>{let t=A(e??``);D.value=t,O.value=j(t)},{immediate:!0});function N(){O.value=j(D.value),M.flush()}function P(e){e.key===`Escape`&&(D.value=E.value??``),T(`update`,D.value),e.key===`Enter`&&N()}function F(){w.disabled||(D.value=``,O.value=j(``),E.value=``,k.value?.focus())}return(n,r)=>(u(),f(b,{id:e.id,title:e.title,description:e.description,required:e.required},m({default:d(()=>[o(`div`,{class:a(e.plain?`_plain`:`oui-input oui-input-container _oui-block-control`),disabled:e.disabled?!0:void 0},[h(n.$slots,`start`),i(o(`input`,c({id:e.id,ref_key:`inputEl`,ref:k,"onUpdate:modelValue":r[0]||=e=>D.value=e,type:e.type,class:e.plain?`_plain`:`oui-input-string`},n.$attrs,{disabled:e.disabled?!0:void 0,"aria-invalid":!O.value||void 0,onKeypress:P,onBlur:N}),null,16,C),[[_,D.value]]),h(n.$slots,`end`),e.clearable&&(E.value||D.value)?(u(),s(`div`,{key:0,class:`oui-input-clearable`,onMousedown:r[1]||=v(()=>{},[`prevent`]),onClick:v(F,[`stop`,`prevent`])},[t(y)],32)):g(``,!0)],10,S)]),_:2},[n.$slots.title?{name:`title`,fn:d(()=>[h(n.$slots,`title`)]),key:`0`}:void 0,n.$slots.description?{name:`description`,fn:d(()=>[h(n.$slots,`description`)]),key:`1`}:void 0]),1032,[`id`,`title`,`description`,`required`]))}});export{w as t};